//Class representing a 3D vector and the operations pertaining to such
public class Vector3D
{
	float x;
	float y;
	float z;
	
	public Vector3D()
	{
		this.x = 0.00f;
		this.y = 0.00f;
		this.z = 0.00f;
	}
	
	public Vector3D(float xa, float ya, float za)
	{
		this.x = xa;
		this.y = ya;
		this.z = za;
	}
	
	public Vector3D(Vector3D v)
	{
		this.x = v.x;
		this.y = v.y;
		this.z = v.z;
	}

	public Vector3D add(Vector3D v)
	{
		Vector3D r = new Vector3D(v);
		r.x += this.x;
		r.y += this.y;
		r.z += this.z;
		return r;
	}
	
	public Vector3D subtract(Vector3D v)
	{
		Vector3D r = new Vector3D(this);
		r.x -= v.x;
		r.y -= v.y;
		r.z -= v.z;
		return r;
	}

	public Vector3D times(float a)
	{
		Vector3D r = new Vector3D(this);
		r.x *= a;
		r.y *= a;
		r.z *= a;
		return r;
	}
	
	public Vector3D divide(float a)
	{
		Vector3D r = new Vector3D(this);
		r.x /= a;
		r.y /= a;
		r.z /= a;
		return r;
	}
	
	public float dot(Vector3D v)
	{
		return ((this.x*v.x)+(this.y*v.y)+(this.z*v.z));
	}
	
	public Vector3D cross(Vector3D v)
	{
		Vector3D r = new Vector3D();
		r.x = (this.y * v.z) - (this.z * v.y);
		r.y = (this.z * v.x) - (this.x * v.z);
		r.z = (this.x * v.y) - (this.y * v.x);
		return r;
	}

	public float modulus()
	{
		return (float)(Math.sqrt((this.x*this.x)+(this.y*this.y)+(this.z*this.z)));
	}
	
	public float modulusSquared()
	{
		return ((this.x*this.x)+(this.y*this.y)+(this.z*this.z));
	}
	
	public Vector3D unit()
	{
        if (this.modulus() != 0)
            return this.divide(this.modulus());
        else
            return this;
	}
	
	public Vector3D opposite()
	{
		Vector3D r = new Vector3D();
		r.x = -(this.x);
		r.y = -(this.y);
		r.z = -(this.z);
		return r;
	}
	
	public void print(String debugStr)
	{
		System.out.println("VECTOR:"+debugStr+":");
		System.out.println(x);
		System.out.println(y);
		System.out.println(z);
	}
	
	boolean isEqualTo(Vector3D v)
	{
		return (this.x == v.x) && (this.y == v.y) && (this.z == v.z);
	}

    public boolean isZero()
    {
        return ((x == 0.0f) && (y == 0.0f) && (z == 0.0f));
    }

    static Vector3D zero()
    {
        return new Vector3D();
    }
}
